Conversation
There was a problem hiding this comment.
Pull request overview
This PR submits Rust coursework projects under submissions/, primarily a Week 3 Day 3 “minigrep”-style CLI (from The Rust Book), but it also includes additional Week 2 Day 3 and Day 5 projects.
Changes:
- Added a Week 3 Day 3 CLI tool crate (
stephenngozi-build-cli-project) with config parsing, file search (case-sensitive/insensitive), and unit tests. - Added a Week 2 Day 5 expense-tracker CLI project that persists expenses to a text file.
- Added a Week 2 Day 3 user-input parsing example project.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| submissions/week-3/day-3/stephenngozi-build-cli-project/src/main.rs | CLI entrypoint: parse args, build config, run search |
| submissions/week-3/day-3/stephenngozi-build-cli-project/src/lib.rs | Core search logic, Config, case-sensitivity toggle, unit tests |
| submissions/week-3/day-3/stephenngozi-build-cli-project/poem.txt | Sample input file for the CLI tool |
| submissions/week-3/day-3/stephenngozi-build-cli-project/output.txt | Captured sample output for a run |
| submissions/week-3/day-3/stephenngozi-build-cli-project/Cargo.toml | Rust crate manifest |
| submissions/week-3/day-3/stephenngozi-build-cli-project/Cargo.lock | Dependency lockfile |
| submissions/week-3/day-3/stephenngozi-build-cli-project/.gitignore | Ignore Rust target/ |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/main.rs | Expense tracker CLI UI loop (add/view/update/delete/save) |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/tracker.rs | ExpenseTracker storage + save-to-file |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/expense.rs | Expense and TransactionType definitions |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/stephen_expences.txt | Example saved output file |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.toml | Rust crate manifest |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.lock | Dependency lockfile |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/.gitignore | Ignore Rust target/ |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/src/main.rs | Simple stdin parsing + enum-based handling |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.toml | Rust crate manifest |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.lock | Dependency lockfile |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/.gitignore | Ignore Rust target/ |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let args: Vec<String> = env::args().collect(); | ||
|
|
||
| let config = Config::new(&args).unwrap_or_else(|err |{ | ||
| eprintln!("Problem parsing argumemts: {}", err); |
There was a problem hiding this comment.
Typo in error message: "argumemts" should be "arguments" so users see a professional, searchable message.
| eprintln!("Problem parsing argumemts: {}", err); | |
| eprintln!("Problem parsing arguments: {}", err); |
| pub fn save_to_file(&self, filename: &str) { | ||
| let mut file = File::create(filename).expect("Could not create file"); | ||
|
|
||
| for expense in self.values.values() { |
There was a problem hiding this comment.
HashMap::values() iteration order is nondeterministic, so save_to_file can write expenses in a random order (the committed stephen_expences.txt already shows IDs out of order). Consider iterating in a stable order (e.g., collect/sort by id, or reuse view_all()).
| for expense in self.values.values() { | |
| for expense in self.view_all().iter() { |
| if tracker.update(id, amount, tx_type){ | ||
| println!("Expense Updated Successfu"); | ||
|
|
||
| if let Some(expense) = tracker.values.get(&id) { | ||
| println!("ID: {}, Name: {}, Amount: Naria{:.2}, Type: {:?}", |
There was a problem hiding this comment.
If tracker.update(...) returns false (ID not found), the user gets no feedback and the program silently continues. Add an else branch to print a not-found message (similar to delete).
| tracker.save_to_file("stephen_expences.txt"); | ||
| println!("Data saved to stephen_expences.txt"); |
There was a problem hiding this comment.
The filename/message uses "expences" (typo). Consider renaming to "stephen_expenses.txt" and updating the saved output file accordingly so naming matches "expenses" throughout.
| tracker.save_to_file("stephen_expences.txt"); | |
| println!("Data saved to stephen_expences.txt"); | |
| tracker.save_to_file("stephen_expenses.txt"); | |
| println!("Data saved to stephen_expenses.txt"); |
| } | ||
| } | ||
| } else if input == "3" { | ||
| println!("Enter the ID of the Expence"); |
There was a problem hiding this comment.
Typo in prompt: "Expence" should be "Expense".
| let id: u8 = id_input.trim().parse().expect("Please enter a valid ID"); | ||
|
|
||
| if tracker.delete(id){ | ||
| println!(" Your Expence is Deleted "); |
There was a problem hiding this comment.
Typo in status message: "Expence" should be "Expense".
| println!(" Your Expence is Deleted "); | |
| println!(" Your Expense is Deleted "); |
|
|
||
| use std::io; | ||
| enum PowerStatus { | ||
| Off, | ||
| Sleep, | ||
| Reboot, |
There was a problem hiding this comment.
PR description says this is a Week 3 Day 3 submission, but this PR also adds Week 2 Day 3 / Day 5 projects. Per the repo submission guidance, week/day submissions should be kept scoped to the relevant folder; consider moving Week 2 additions into separate PR(s).
| }); | ||
|
|
||
|
|
||
| println!(" searching for {}", config.query); |
There was a problem hiding this comment.
The log line has a leading space in the format string, which makes output inconsistent (see output.txt) and harder to copy/paste. Consider removing the leading whitespace.
| println!(" searching for {}", config.query); | |
| println!("searching for {}", config.query); |
| pub fn save_to_file(&self, filename: &str) { | ||
| let mut file = File::create(filename).expect("Could not create file"); |
There was a problem hiding this comment.
save_to_file panics on file creation/write errors via expect. For a CLI, it’s better to return a Result (or bubble up an io::Result) so the caller can report the error without crashing.
| println!("ID: {} | Name: {} | Amount: Naria{:.2} | Type: {:?}", | ||
| expense.id, expense.name, expense.amount, expense.tx_type); |
There was a problem hiding this comment.
Typo in output label: "Naria" is likely meant to be "Naira".
Task Submission PR
Student Info:
Task Details:
Checklist Before Submitting:
Additional Comments:
If any, mention here.